﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Collections.Specialized;

public static class HtmlExtensions
{
    public static IHtmlString UsedDateStyle(this HtmlHelper html, DateTime value)
    {
        if (value <= DateTime.Now)
        {
            return new HtmlString("style='background-color:#BAD6FF;'");
        }
        if (value > DateTime.Now)
        {
            return new HtmlString("");
        }
        return new HtmlString("");
    }

    public static IHtmlString VacationsAmountWarning(this HtmlHelper html, int? value)
    {
        if (value >= 12)
        {
            return new HtmlString("style='background-color:#ffcfcf;'");
        }
        return new HtmlString("");
    }

    public static RouteValueDictionary ToRouteValues(this NameValueCollection queryString)
    {
        if ( queryString == null || queryString.HasKeys() == false) return new RouteValueDictionary();

        var routeValues = new RouteValueDictionary();
        foreach (string key in queryString.AllKeys)
        {
            if (key.Equals("activeBool"))
            {
                routeValues.Add(key, queryString[key].Split(',')[0]);
            }
            else
            {
                routeValues.Add(key, queryString[key]);
            }
        }

        return routeValues;
    }
}